<?php
namespace App\Models\Mysql;

use App\Traits\SupplierDbConnections;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

/**
* @comment 商户表
*
* @property int $id
* @property string $name 商户姓名
* @property string $nickname 昵称
* @property string $merchant_number 商户号
* @property string $phone 手机号
* @property string $password 密码
* @property float $balance 余额
* @property float $deduction_balance 扣款余额
* @property string $transaction_password 交易密码
* @property string $secret_key 商户密钥
* @property int $is_on 1 = 已经添加信息完毕  2 = 没有添加id以及账户信息
* @property float $merchant_balance_alarm 余额报警阀门
* @property float $ranges 税率
* @property int $is_goodsopen 1.开 2.关
* @property int $multiple_landing 1 = 多人  2 = 单人
* @property string $wechat_openid 微信用户的openid
* @property int $is_certification 1.已实名 2.未实名
* @property int $time 注册时间
* @property int $status 1.通过 2.未通过3.审核中
* @property int $merchant_type 1 = 不带票商户   2 = 带票商户
 *
*/
class XnMerchant extends Authenticatable implements JWTSubject
{
    use Notifiable, SupplierDbConnections;

    /**
     * @var string
     */
    protected $table = 'xn_merchant';

    /**
     * @var bool
     */
    public $timestamps = false;

    /**
     * @var string[]
    */
    protected $fillable = ['id', 'name', 'nickname', 'merchant_number', 'phone', 'password', 'balance', 'deduction_balance', 'transaction_password', 'secret_key', 'is_on', 'merchant_balance_alarm', 'ranges', 'is_goodsopen', 'multiple_landing', 'wechat_openid', 'is_certification', 'time', 'status', 'merchant_type'];

    /**
     * @return HasOne
     */
    public function mechantinfos(): HasOne
    {
        return $this->hasOne(XnMechantInfos::class,'merchant_id');
    }

    /**
     * @return mixed
     */
    public function getJWTIdentifier(): mixed
    {
        return $this->getKey();
    }

    /**
     * @return array
     */
    public function getJWTCustomClaims(): array
    {
        return [];
    }

    /**
     * @return string
     */
    function getAuthPassword(): string
    {
        return $this->password;
    }
}
